<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
	font-size: 18px;
	font-weight: bold;
}
.style2 {
	font-size: 24px;
	font-weight: bold;
	color: #000000;
}
body {
	background-color: #A7BFDB;
}
.style4 {
	color: #000000;
	font-weight: bold;
}
.style5 {color: #000000; }
-->
</style>
</head>

<body>
<%

try
	  {
			Class.forName("org.postgresql.Driver");
			Connection con = DriverManager.getConnection("jdbc:postgresql://localhost/ses","postgres","postgres");
			
			if (request.getParameter("usuario") != null)
			{
				Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
	            ResultSet.CONCUR_READ_ONLY); 
				ResultSet rs = st.executeQuery("select * from funcionario where nome = '"+
				request.getParameter("usuario")+"' and senha = '"+
				request.getParameter("senha")+"'");
			
				if (rs.next())
				{
				    response.sendRedirect("menu.jsp");
				   
				}   
				else
				   out.println("você não tem acesso ao sistema");   
			}  		  
	  }
	  catch(ClassNotFoundException erroClass)
	  {
	     out.println("Classe Driver JDBC não foi localizado, erro = "+erroClass);
	  }
	  catch(SQLException erroSQL)
	  {
  	     out.println("Erro de conexão com o Banco de dados, erro = "+erroSQL);
	  }

%>
<form id="form1" name="form1" method="post" action="">
  <div align="center">
    <p class="style1">&nbsp;</p>
    <p class="style2 style5">Bem Vindo ao Sistema de Planejamento de Custos</p>
    <p class="style1">&nbsp;</p>
    <p class="style1">&nbsp;</p>
    <p class="style1">&nbsp;</p>
    <table width="200" border="1">
      <tr>
        <td colspan="2"><div align="center" class="style4">ACESSO AO SISTEMA</div></td>
      </tr>
      <tr>
        <td width="91"><div align="center" class="style5">Usuário</div></td>
        <td width="93"><label>
          <div align="center">
            <input name="usuario" type="text" id="usuario" size="10" />
            </div>
        </label></td>
      </tr>
      <tr>
        <td><div align="center" class="style5">Senha</div></td>
        <td><label>
          <div align="center">
            <input name="senha" type="password" id="senha" size="12" />
            </div>
        </label></td>
      </tr>
      <tr>
        <td><label>
          <div align="center">
            <input type="submit" name="acesso" id="acesso" value="Acessar" />
            </div>
        </label></td>
        <td><label>
          <div align="center">
            <input type="submit" name="limpa" id="limpa" value="Limpar" />
            </div>
        </label></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p class="style5"><strong>Desenvolvido por SES - Software Enginnering Solution</strong></p>
  </div>
</form>
</body>
</html>
